const Animate = require("../gmoon/libs/elemAnimate");

class anima extends Animate{
    "test-animate"( res , rej ){
        console.log( "test-animate" );
        res();
    }

    //每局开始时候需要展示的信息
    "show-level-begin"( res ){
        let hos = this._elem;
        hos.playChildAnimate([
            {
                name : "mask",
                conf : {
                    sprite : $RES.g("img-mask-black"),
                    pos : cc.v2(0 , 400),
                    offsetPos : cc.v2(0 , 600),
                    zIndex : 1,
                    blockInput : 1,
                    opacity : 100,
                    mask : true
                },
                scale : 0,
                time : .1,
                delay : 0,
                easing : {easing: 'sineOut'},
                click : ()=>{
                    this.do("un-show-level-begin")
                    .then(()=>{
                        res && res( true );
                    })
                }
            },
            {
                name : "levelpanel",
                offsetPos : cc.v2(-800 , 0),
                scale : 0,
                time : .2,
                delay : 0,
                easing : {easing: 'sineOut'},
                fn : ()=>{
                    // let elmnode = hos.node;
                    // let node = $G.do("oneNode.get" , "tmpmask");
                    // node.width = elmnode.width;
                    // node.height = elmnode.height;
                    // node.parent = elmnode;
                    // node.setPosition(cc.v2(0,0));
                    // node.on( cc.Node.EventType.TOUCH_START , ()=>{
                    //     $G.do("oneNode.put" , node  , "tmpmask");
                    //     this.do("hide-level-begin")
                    //     .then(()=>{
                    //         res && res( true );
                    //     })
                    // })
                }
            },
            {
                name : "tipks",
                offsetPos : cc.v2(0 , 0),
                scale : 0,
                time : .2,
                delay : 1,
                easing : {easing: 'sineOut'},
            }
        ])
    }

    "un-show-level-begin"( res ){
        let hos = this._elem;
        hos.playChildAnimate([
            {
                name : "levelpanel",
                offsetPos : cc.v2(0 , 0),
                scale : 0,
                time : .1,
                delay : 0,
                easing : {easing: 'sineOut'},
                fn : ()=>{
                }
            },
            {
                name : "tipks",
                offsetPos : cc.v2(0 , 0),
                scale : 0,
                time : .1,
                easing : {easing: 'sineOut'},
            },
            {
                name : "mask",
                scale : 0,
                time : .1,
                delay : .3,
                easing : {easing: 'sineOut'},
                fn : ()=>{
                    res && res()
                }
            }
        ] , true )
    }

    //过关动画
    "game-success-film"( res ){
        let hos = this._elem;
        hos.playChildAnimate([
            {
                name : "mask",
                conf : {
                    sprite : $RES.g("img-mask-black"),
                    pos : cc.v2(0 , 400),
                    offsetPos : cc.v2(0 , 600),
                    zIndex : 1,
                    blockInput : 1,
                    opacity : 100,
                    mask : true
                },
                scale : 0,
                time : .1,
                delay : 0,
                easing : {easing: 'sineOut'},
                click : ()=>{},
                fn : ()=>{
                    console.log("suc film click");
                }
            },
            {
                name : "successlogo",
                offsetPos : cc.v2(0 , 600),
                scale : 0,
                time : .1,
                delay : 0,
                easing : {easing: 'sineOut'},
                fn : ()=>{
                }
            },
            {
                name : "getcoins",
                offsetPos : cc.v2(-800 , 0),
                scale : 0,
                time : .2,
                delay : .2,
                easing : {easing: 'sineOut'},
                click : ( node )=>{
                    $Animate.do("playPop" ,  node , 0 , {u:.1,d:-.1});
                    res( 1 );
                },
                fn : ()=>{
                }
            },
            {
                name : "getcoins4x",
                offsetPos : cc.v2(800 , 0),
                scale : 0,
                time : .2,
                delay : .2,
                click : ( node )=>{
                    $Animate.do("playPop" ,  node , 0 , {u:.1,d:-.1});
                    res && res( 4 )
                },
                easing : {easing: 'sineOut'},
            }
        ])

    }

    "un-game-success-film"( res ){
        let hos = this._elem;
        hos.playChildAnimate([
            {
                name : "successlogo",
                offsetPos : cc.v2(0 , 600),
                scale : 0,
                time : .1,
                delay : 0,
                easing : {easing: 'sineOut'}
            },
            {
                name : "getcoins",
                offsetPos : cc.v2(-800 , 0),
                scale : 0,
                time : .2,
                delay : .2,
                easing : {easing: 'sineOut'}
            },
            {
                name : "getcoins4x",
                offsetPos : cc.v2(800 , 0),
                scale : 0,
                time : .2,
                delay : .2
            },

            {
                name : "mask",
                scale : 0,
                time : .1,
                delay : .5,
                easing : {easing: 'sineOut'},
                fn : ()=>{
                    res();
                }
            }
        ] , true )
    }

    //失败动画
    "game-fail-film"( res ){
        let hos = this._elem;
    }
}

module.exports = anima; 